package com.tywj.navigation.course

import android.os.Bundle
import android.os.Handler
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.tywj.panda.customer.common.view.base.MyBaseActivity
import com.tywj.lib.core.common.extension.onClick
import com.tywj.navigation.R
import com.tywj.navigation.entity.NavigationApplyHistoryEntity
import com.tywj.navigation.map.NavigationApplyCourseAdapter
import com.tywj.navigation.route.NavigationRoute
import kotlinx.android.synthetic.main.navigation_activity_history.*

/**
 * @desc 申请记录
 * @author June Yang
 * @date 2020/5/21
 */

@Route(path = NavigationRoute.NAVIGATION_APPLY_HISTORY)
class NavigationApplyHistoryActivity : MyBaseActivity() {


    private lateinit var mAdapter: NavigationApplyCourseAdapter

    private var list = ArrayList<NavigationApplyHistoryEntity>()

    override fun getLayoutID(): Int = R.layout.navigation_activity_history

    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        initRecyclerView()

        //禁用上拉刷新和下拉加载更多
        mAdapter.setEnableLoadMore(false)
        swipeRefreshLayout.isEnabled = false

    }

    override fun initListener() {
        super.initListener()

        titleLayout.getRightImageButton().onClick {
            finish()
        }
    }

    override fun loadDataOnCreate() {
        super.loadDataOnCreate()

        statusLayout.showLoadingLayout()
        Handler().postDelayed({
            tempData()
        }, 500)

    }

    private fun initRecyclerView() {
        mAdapter = NavigationApplyCourseAdapter()
        rvList.adapter = mAdapter
        rvList.layoutManager = LinearLayoutManager(this)
    }

    private fun tempData() {
        for (i in 0..20) {
            val bean = NavigationApplyHistoryEntity()
            bean.busLineName = "新城佳苑站-青蓉国际广场$i"
            bean.time = "出发: 07:00 - 返回:1 5:00 $i"
            bean.remark = "无$i"
            bean.num = i
            list.add(bean)
        }
        statusLayout.showContentLayout()
        mAdapter.setNewData(list)
    }
}
